// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_img.p_video;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.graphics.*;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.*;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;

// Referenced classes of package com.nnee.p_img.p_video:
//            MonitoredActivity, h, al, k, 
//            CropImageView, i, ao, l, 
//            n, j

public class cls_ActivityCropImage extends cls_MonitoredActivity
{

    public cls_ActivityCropImage()
    {
        e = android.graphics.Bitmap.CompressFormat.JPEG;
        f = null;
        g = false;
        h = true;
        d = new cls_h(this);
    }

    static Bitmap a(cls_ActivityCropImage cls_ActivityCropImage, Bitmap bitmap)
    {
        cls_ActivityCropImage.l = bitmap;
        return bitmap;
    }

    public static void a(Activity activity, int i1, Bitmap bitmap)
    {
        Intent intent = new Intent(activity, com.nnee.p_img.p_video.cls_ActivityCropImage.class);
        intent.setAction("set_wallpaper");
        Bundle bundle = new Bundle();
        bundle.putParcelable("data", bitmap);
        bundle.putBoolean("wallpaper", true);
        intent.putExtras(bundle);
        intent.addFlags(0x4000000);
        activity.startActivityForResult(intent, i1);
    }

    public static void a(Activity activity, int i1, Bitmap bitmap, Uri uri, String s)
    {
        Intent intent = new Intent(activity, com.nnee.p_img.p_video.cls_ActivityCropImage.class);
        intent.setAction("save");
        Bundle bundle = new Bundle();
        bundle.putParcelable("data", bitmap);
        bundle.putParcelable("output", uri);
        bundle.putString("format", s);
        intent.putExtras(bundle);
        activity.startActivityForResult(intent, i1);
    }

    private void a(Bitmap bitmap)
    {
        java.io.OutputStream outputstream;
        boolean flag;
        if(f == null)
            return;
        outputstream = null;
        flag = true;
        try {
			outputstream = k.openOutputStream(f);
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
        if(outputstream != null)
            bitmap.compress(e, 75, outputstream);
        cls_al.a(outputstream);

        Bundle bundle1 = new Bundle();

        if(flag)
            setResult(-1, (new Intent(f.toString())).putExtras(bundle1));
        else
            setResult(0);

        i.post(new cls_k(this, bitmap));
        finish();
        return;
//        ioexception1;
//        ioexception1.printStackTrace();
//        al.a(outputstream);
//        flag = false;
//          goto _L1
//        exception;
//        al.a(outputstream);
//        throw exception;
//        if(g)
//        {
//            try
//            {
//                setWallpaper(bitmap);
//                setResult(-1);
//            }
//            catch(IOException ioexception)
//            {
//                ioexception.printStackTrace();
//                setResult(0);
//            }
//        } else
//        {
//            Bundle bundle = new Bundle();
//            bundle.putParcelable("data", bitmap);
//            setResult(-1, (new Intent()).putExtras(bundle));
//        }
//          goto _L2
    }

    static void a(cls_ActivityCropImage cls_ActivityCropImage)
    {
        cls_ActivityCropImage.c();
    }

    static Bitmap b(cls_ActivityCropImage cls_ActivityCropImage)
    {
        return cls_ActivityCropImage.l;
    }

    private void b()
    {
        if(!isFinishing())
        {
            j.a(l, true, true);
            cls_al.a(this, null, getString(0x7f0a017e), new cls_i(this), i);
        }
    }

    public static void b(Activity activity, int i1, Bitmap bitmap)
    {
        Intent intent = new Intent(activity, com.nnee.p_img.p_video.cls_ActivityCropImage.class);
        intent.setAction("crop");
        Bundle bundle = new Bundle();
        bundle.putParcelable("data", bitmap);
        bundle.putBoolean("wallpaper", false);
        intent.putExtras(bundle);
        activity.startActivityForResult(intent, i1);
    }

    static void b(cls_ActivityCropImage cls_ActivityCropImage, Bitmap bitmap)
    {
        cls_ActivityCropImage.a(bitmap);
    }

    static cls_CropImageView c(cls_ActivityCropImage cls_ActivityCropImage)
    {
        return cls_ActivityCropImage.j;
    }

    private void c()
    {
        if(c != null && !b)
        {
            b = true;
            Rect rect = c.b();
            int i1 = rect.width();
            int j1 = rect.height();
            Bitmap bitmap = Bitmap.createBitmap(i1, j1, android.graphics.Bitmap.Config.RGB_565);
            Canvas canvas = new Canvas(bitmap);
            Rect rect1 = new Rect(0, 0, i1, j1);
            canvas.drawBitmap(l, rect, rect1, null);
            j.a();
            l.recycle();
            j.a(bitmap, true, true);
            j.a(true, true);
            j.a.clear();
            String s;
            if(g)
                s = getString(0x7f0a017f);
            else
                s = getString(0x7f0a0180);
            cls_al.a(this, null, s, new cls_l(this, bitmap), i);
        }
    }

    static Handler d(cls_ActivityCropImage cls_ActivityCropImage)
    {
        return cls_ActivityCropImage.i;
    }

    static boolean e(cls_ActivityCropImage cls_ActivityCropImage)
    {
        return cls_ActivityCropImage.h;
    }

    public void onCreate(Bundle bundle)
    {
        Intent intent;
        Bundle bundle1;
        super.onCreate(bundle);
        k = getContentResolver();
        requestWindowFeature(1);
        setContentView(0x7f03000b);
        j = (cls_CropImageView)findViewById(0x7f0d0024);
        intent = getIntent();
        bundle1 = intent.getExtras();
        if(bundle1 != null) {
        	l = (Bitmap)bundle1.getParcelable("data");
            if(!"save".equals(intent.getAction())) {
                if("set_wallpaper".equals(intent.getAction()))
                    g = bundle1.getBoolean("wallpaper");
                else
                if("crop".equals(intent.getAction()))
                    g = false;
                  
            } else {
            	f = (Uri)bundle1.getParcelable("output");
                String s = bundle1.getString("format");
                if(s != null)
                    e = android.graphics.Bitmap.CompressFormat.valueOf(s);
            }
        } else {
        	finish();
        }
        
        if(l == null)
        {
            finish();
        } else
        {
            getWindow().addFlags(1024);
            findViewById(0x7f0d0026).setOnClickListener(new cls_n(this));
            findViewById(0x7f0d0025).setOnClickListener(new cls_j(this));
            b();
        }
    }

    public boolean onKeyDown(int i1, KeyEvent keyevent)
    {
        return super.onKeyDown(i1, keyevent);
    }

    boolean a;
    boolean b;
    cls_ao c;
    Runnable d;
    private android.graphics.Bitmap.CompressFormat e;
    private Uri f;
    private boolean g;
    private boolean h;
    private final Handler i = new Handler();
    private cls_CropImageView j;
    private ContentResolver k;
    private Bitmap l;
}
